package org.django4j;

import com.hoursebet.common.SystemException;

public class ModelHandlerFactory {
    
    /**
     * 根据viewtype获得相应的ModelHandler实例
     */
    public static ModelHandler getHandler(String viewType){
        if (viewType == null){
            throw new IllegalArgumentException("argument 'viewType' can NOT be null.");
        }
        
        ModelHandler handler = null;
        if (Model.TYPE_JAVA.equals(viewType)){
            handler = new JavaSerializationModelHandler();
        }
        else if (Model.TYPE_TEXT.equals(viewType)){
            handler = new TextModelHandler();
        }
        else{
            throw new SystemException("NOT supported viewtype: " + viewType);
        }
        return handler;
    }
}
